package org.sumkid.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.lang.NonNull;
import org.springframework.transaction.annotation.Transactional;
import org.sumkid.entity.User;

import java.util.List;

/**
 * Default Description
 *
 * @author sumkid
 * @since 2022/10/1
 */
public interface UserRepository extends JpaRepository<User, Integer> {
    List<User> findByManagerId(@NonNull Long managerId);

    @Transactional
    @Modifying
    @Query("update User u set u.age = ?1 where u.id = ?2")
    int updateAgeById(@NonNull Integer age, @NonNull Long id);

}
